home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / unixlib.lha / unix / src / _exit.c next >
C/C++ Source or Header  |  1996-10-09  |  635b  |  40 lines

  1. #include "amiga.h"
  2. #include "files.h"
  3. #include "fifofd.h"
  4. #include "signals.h"
  5. #include "timers.h"
  6. #include <fcntl.h>
  7.  
  8. extern int __close(int fd);
  9.  
  10. void _close_all(void)
  11. {
  12.     int fd, lfd = _last_fd();
  13.  
  14.     for (fd = 0; fd < lfd; fd++)
  15.     __close(fd);
  16. }
  17.  
  18. void __saveds __exit(int rc)
  19. {
  20.     /*
  21.      * I really don't know why I should flush stdout here! If not done
  22.      * a crash is very likely. SAS C misteries ...
  23.      */
  24.     fflush(stdout);
  25.     _close_all();
  26.     _cleanup_fifo();
  27.     _cleanup_signals();
  28.     _free_timer(_odd_timer);
  29.     _XCEXIT(rc);
  30. }
  31.  
  32. #ifdef _exit
  33. #undef _exit
  34. #endif
  35.  
  36. void __saveds _exit(int rc)
  37. {
  38.     __exit(rc);
  39. }
  40.